/*
Copyright (C) 2011  João Dias de Carvalho Neto

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
import br.com.mysm.components.LoginWindow.LoginFailsEvent;
import br.com.mysm.components.LoginWindow.LoginSuccessEvent;
import br.com.mysm.global.AssetMapper;
import br.com.mysm.global.Util;

import flash.external.ExternalInterface;
import flash.net.URLRequest;

import mx.managers.CursorManager;
import mx.resources.ResourceBundle;


/**
 * Callback dispatched when de module LoginWindow creation is complete
 */
private function onCreationComplete():void
{
	this.resourceManager.localeChain = [Util.defaultLocale];
}

/**
 *Callback dispached when the txtLogin Object is created 
 */
private function onTxtLoginCreationComplete():void
{
	this.focusManager.setFocus(this.txtLogin);
}

/**
 * Internal method to check if user is a valid user  
 * @param userName
 * @param passWord
 * @return Boolean
 * 
 */
private function checkUserIsValid(userName:String, passWord:String):Boolean
{
	return false;
}

/**
 * Callback dispatched when the user presses the login Button 
 */
private function onButtonLoginClick():void
{
	if (this.checkUserIsValid(this.txtLogin.text,this.txtPasswd.text))
	{
		var ev:LoginSuccessEvent = new 
			LoginSuccessEvent(LoginSuccessEvent.LOGIN_SUCCESS);
		this.dispatchEvent(ev);
	}
	else
	{
		var ev1:LoginFailsEvent = new 
			LoginFailsEvent(LoginFailsEvent.LOGIN_FAILS);
		this.dispatchEvent(ev1);
	}
}


